package com.deer.wms.base.system.web.task;

import com.deer.wms.base.system.model.task.BoxTrace;
import com.deer.wms.base.system.service.task.BoxTraceService;
import com.deer.wms.common.core.controller.BaseController;
import com.deer.wms.common.core.page.TableDataInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author 申紫微
 * @version 1.0
 * @description
 * @data 2020-10-13 10:02:15
 */
@Controller
@RequestMapping("/taskFollow")
public class BoxTraceController extends BaseController {

    @Autowired
    private BoxTraceService boxTraceService;

    private String prefix = "task";

    @RequiresPermissions("boxTraceView:view")
    @GetMapping
    public String findList(){
        return prefix + "/boxTrace";
    }

    /*
     * 查询正在执行的任务的设备追踪信息
     * @author 申紫微
     * @date 10:31 2020/10/13
     * @params boxTrace
     * @return  com.deer.wms.common.core.page.TableDataInfo
     **/
    @RequiresPermissions("boxTraceView:list")
    @RequestMapping("findListOfExecuting")
    @ResponseBody
    public TableDataInfo findListOfExecuting(BoxTrace boxTrace){
        startPage();
        List<BoxTrace> listOfExecuting = boxTraceService.findListOfExecuting(boxTrace);
        return getDataTable(listOfExecuting);
    }

    /*
     * 通过任务号查询任务经过的所有设备的信息
     * @author 申紫微
     * @date 14:54 2020/10/13
     * @params taskId
     * @return  com.deer.wms.common.core.page.TableDataInfo
     **/
    @RequiresPermissions("boxTraceView:list")
    @RequestMapping("findTaskHistoryDeviceName")
    @ResponseBody
    public TableDataInfo findHistoryDeviceName(Integer taskId){
        startPage();
        List<BoxTrace> list = boxTraceService.findListByTaskId(taskId);
        return getDataTable(list);
    }

    /**
     * 查询历史任务经过的设备的信息
     * @author 申紫微
     * @date 10:32 2020/10/13
     * @params boxTrace
     * @return com.deer.wms.common.core.page.TableDataInfo
     **/
    @RequiresPermissions("boxTraceView:list")
    @RequestMapping("findListOfHistoryBoxTrace")
    @ResponseBody
    public TableDataInfo findListHistoryBoxTrace(BoxTrace boxTrace){
        startPage();
        List<BoxTrace> listHistoryBoxTrace = boxTraceService.findListHistoryBoxTrace(boxTrace);
        return getDataTable(listHistoryBoxTrace);
    }

}
